package com.itheima.web.controller;

import com.github.pagehelper.PageInfo;
import com.itheima.domain.SysLog;
import com.itheima.service.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/sysLog")
public class SysLogController {

    @Autowired
    private ISysLogService sysLogService;

    @RequestMapping("/findAllSysLog")
    public String findAllSysLog(
            Model model,
            @RequestParam(name = "pageNum", required = true, defaultValue = "1") Integer pageNum,
            @RequestParam(name = "pageSize", required = true, defaultValue = "3") Integer pageSize) {

        List<SysLog> sysLogList = sysLogService.findAllSysLog(pageNum, pageSize);

        PageInfo<SysLog> pageInfo = new PageInfo<SysLog>(sysLogList);

        model.addAttribute("sysLog",pageInfo);

        return "syslog-list";
    }


}
